<script setup>
import {
  Edit,
  Delete
} from '@element-plus/icons-vue'
import { ref } from 'vue'
const categorys = ref([
  {
    "itemId": 3,
    "description": "混凝土意大利面",
    "image": "https://web-tlias-zxz.oss-cn-beijing.aliyuncs.com/08824781-7e33-4ff0-bd32-197c89225790.jpg",
    "price": "23.00",
    "number": 111,
    "createTime": "2023-09-02 12:06:59",
    "updateTime": "2023-09-02 12:06:59"
  }, {
    "itemId": 3,
    "description": "老八汉堡",
    "image": "https://web-tlias-zxz.oss-cn-beijing.aliyuncs.com/08824781-7e33-4ff0-bd32-197c89225790.jpg",
    "price": "23.00",
    "number": 111,
    "createTime": "2023-09-02 12:06:59",
    "updateTime": "2023-09-02 12:06:59"
  }, {
    "itemId": 3,
    "description": "塔吊冰红茶",
    "image": "https://web-tlias-zxz.oss-cn-beijing.aliyuncs.com/08824781-7e33-4ff0-bd32-197c89225790.jpg",
    "price": "23.00",
    "number": 111,
    "createTime": "2023-09-02 12:06:59",
    "updateTime": "2023-09-02 12:06:59"
  },
])
//商品名称搜索
const selectItemName = ref('')

//控制添加分类弹窗
const dialogVisible = ref(false)
//定义变量控制标题展示
const title = ref('')



</script>





<template>
  <el-card class="page-container">
<!--    商品头部标题-->
    <template #header>
      <div class="header">
        <span>商品展示</span>
        <div class="extra">
          <el-button type="primary" @click="dialogVisible = true, title='添加商品',console.log('11111111111111111111111111111111111111')">添加商品</el-button>
        </div>
      </div>
    </template>
    <el-form inline>
<!--      商品名称搜索框-->
      <el-form-item label="商品名称：">
<!--        请选择的框-->
        <!--            <el-select placeholder="请选择" v-model="categoryId" style="width: 240px">
                     <el-option
                         v-for="c in categorys"
                         :key="c.id"
                         :label="c.categoryName"
                         :value="c.id">
                     </el-option>
            </el-select>-->

        <el-input v-model="selectItemName" style="width: 240px" placeholder="请输入商品名称" />
      </el-form-item>
<!--      搜索重置按钮-->
      <el-form-item>
        <el-button type="primary" @click="articleList()">搜索</el-button>
        <el-button @click="selectItemName='' ">重置</el-button>
      </el-form-item>
    </el-form>

<!--    商品列表-->
    <el-table :data="categorys" style="width: 100%">
      <el-table-column label="序号" width="100" type="index"> </el-table-column>
      <el-table-column label="商品名称" prop="description"></el-table-column>
      <el-table-column label="商品图片" prop="image"></el-table-column>
      <el-table-column label="商品价格(时)" prop="price"></el-table-column>
      <el-table-column label="商品数量" prop="number"></el-table-column>
      <el-table-column label="操作" width="100">
        <template #default="{ row }">
          <el-button :icon="Edit" circle plain type="primary" ></el-button>
          <el-button :icon="Delete" circle plain type="danger"></el-button>
        </template>
      </el-table-column>
      <template #empty>
        <el-empty description="小时时  正在加载数据..." />
      </template>
    </el-table>
  </el-card>


    <!-- 添加    添加/修改 商品的弹窗 -->
    <el-dialog
    v-model="dialogVisible"
    :title=title
    width="500"
    align-center
  >
    <span>后面放表单等--按钮等</span>
    <span>后面放表单等--按钮等</span>
    <span>后面放表单等--按钮等</span>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="dialogVisible = false">
          确认
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<style lang="scss" scoped>
.page-container {
  min-height: 100%;
  box-sizing: border-box;

  .header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}
</style>